package com.isfto.dao;


import com.isfto.entity.tablepojo.FlightChange;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface FlightChangeEnterDao {
    /**
     * 进港航班变更数据
     * @param flightChange
     * @return
     */
    @Insert("insert into flightchangeenter(cfno,startapcd,startfptt,endapcd,endfplt,name,email,changereason,flid) " +
            "values(#{cfno},#{startapcd},#{startfptt},#{endapcd},#{endfplt},#{name},#{email},#{changereason},#{flid})")
    int saveInfo(FlightChange flightChange);
    /**
     * 修改审核状态
     */
    @Update("update flightchangeenter set status=#{status} where cfno=#{cfno} and startapcd=#{startapcd} and endapcd=#{endapcd} and startfptt=#{startfptt} and endfplt=#{endfplt}")
    int updateStauts(FlightChange flightChange);
    /**
     * 查询进港航班数据
     * @return
     */
    @Select("select * from flightchangeenter limit #{page},#{pageSize}")
    List<FlightChange> flightChange(Integer page,Integer pageSize);

    /**
     * 条件查询数据
     * @param cfno
     * @param startapcd
     * @param endapcd
     * @return
     */
    @Select("select * from flightchangeenter where cfno=#{cfno} and startapcd=#{startapcd} and endapcd=#{endapcd} and startfptt=#{startfptt} and endfplt=#{endfplt}")
    FlightChange beforeInfoEnter(@Param("cfno") String cfno,@Param("startapcd") String startapcd,@Param("endapcd") String endapcd,@Param("startfptt")String startfptt,@Param("endfplt")String endfplt);
    /**
     * 进港航班总数
     * @return
     */
    @Select("select count(*) from flightchangeenter")
    int total();

    /**
     * 进港条件查询数据
     * @param startapcd
     * @param endapcd
     * @param startfptt
     * @param endfplt
     * @return
     */
    @Select(" select * from flightchangeenter where startapcd=#{startapcd} and endapcd=#{endapcd} and startfptt>=#{startfptt} and endfplt<=#{endfplt} limit #{page},#{pageSize}")
    List<FlightChange> flightChangeInfo(@Param("startapcd") String startapcd, @Param("endapcd") String endapcd,@Param("startfptt") String startfptt,@Param("endfplt") String endfplt,@Param("page")Integer page,@Param("pageSize")Integer pageSize);

    /**
     * 进港符合条件总个数
     * @param startapcd
     * @param endapcd
     * @param startfptt
     * @param endfplt
     * @return
     */
    @Select(" select count(*) from flightchangeenter where startapcd=#{startapcd} and endapcd=#{endapcd} and startfptt>=#{startfptt} and endfplt<=#{endfplt}")
    Integer flightChangeCount(@Param("startapcd") String startapcd, @Param("endapcd") String endapcd,@Param("startfptt") String startfptt,@Param("endfplt") String endfplt);

    @Update("update flightchangeenter set endfplt=#{endfplt} where flid=#{flid} and cfno=#{cfno}")
    int upFlightChangeEnter(@Param("endfplt") String endfplt,@Param("flid") String flid,@Param("cfno") String cfno);

}
